var cb = require("./13_cb");
var isArrayLike = require("./15_isArrayLike");
var keys = require("./07_keys");

function every(obj, predicate, context) {
  predicate = cb(predicate);
  var ks = !isArrayLike(obj) && keys(obj),
    length = (ks || obj).length;

  for (var i = 0; i < length; ++i) {
    var currentKey = ks ? ks[i] : i;
    if (!predicate(obj[currentKey], currentKey, obj)) {
      return false;
    }
  }
  return true;
}

module.exports = every;
